package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Recruit;
import cn.wolfcode.crm.mapper.RecruitMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.service.IRecruitService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecruitServiceImpl implements IRecruitService{

    @Autowired
    private RecruitMapper recruitMapper;
    @Override
    public void deleteByPrimaryKey(Long id) {
        recruitMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(Recruit record) {
        recruitMapper.insert(record);
    }

    @Override
    public Recruit selectByPrimaryKey(Long id) {
        return recruitMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Recruit> selectAll() {
        return recruitMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Recruit record) {
        recruitMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult query(QueryForObject qo) {
        int total=recruitMapper.queryForCount(qo);
        if(total==0){
            return new PageResult();
        }
        List<Recruit> rows=recruitMapper.queryForList(qo);
        return new PageResult(total,rows);
    }
}
